<template>
    <div class="background">
        <div class="login-container">
            <h2>登录界面</h2>
            <input type="text" v-model="username" placeholder="用户名" />
            <input type="password" v-model="password" placeholder="密码" />
            <button @click="login">登录</button>
        </div>
    </div>
</template>

<script>
    // import querystring from "querystring"

    export default{
        // 返回对应变量
        data(){
            return {
                username:"",
                password:"",
            }
        },

        // 触发事件
        methods:{
            login(){
                // this.$axios
                this.$axios.post("http://localhost:8080/api/user/login", {  
                username: this.username,  
                password: this.password,  
            })
            .then(res => {  
                console.log(res.data);  
                // 处理成功登录后的逻辑  
            })  
            .catch(error => {  
                console.error("请求失败:", error);  
                // 处理登录失败的情况  
            }); 
            }
        },

    }

</script>

<style scoped>
.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://haowallpaper.com/link/common/file/getCroppingImg/15477790061465920'); /* 替换为你的背景图像 URL */
    background-size: cover;
    background-position: center;
}

.login-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.8); /* 半透明背景 */
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    text-align: center;
}

input {
    display: block;
    margin: 10px auto;
    padding: 10px;
    width: 80%;
    border: 1px solid #ccc;
    border-radius: 5px;
}

button {
    padding: 10px;
    width: 80%;
    border: none;
    border-radius: 5px;
    background-color: #007BFF;
    color: white;
    cursor: pointer;
}

button:hover {
    background-color: #0056b3;
}
</style> 
